#ifndef _Shark_Logger_h__
#define _Shark_Logger_h__
#include <stdarg.h>

#include "os/types.h"

#pragma  pack (push,1)
typedef struct {
	u16 id;
	s32 value;
}log_chan_t;
#pragma pack(pop)

void log_start_task(void);
void log_chan_value(u16 id, s32 value) ;

#define L_disable 0
#define L_debug  3
#define L_warning 2
#define L_error 1

#define LEVEL_MASK 0x03

#define mod_bit_start(mod) (mod*2)


/* define the module which need debug info here 
* at most is 32 modules (index from 0 - 31) 
*/
#define MOD_4G_AT 0  //for 4G at
#define MOD_NETWORK 1 // for network 
#define MOD_BUSINESS 2 // for business
#define MOD_BLE      3 //for ble
#define MOD_SYSTEM    4
#ifndef USE_MEX_CMD
extern void set_log_level(int mod, int l);
extern void log_debug(int mod, char *fmt, ...);
extern void log_warning(int mod, char *fmt, ...);
extern void log_error(int mod, char *fmt, ...);
void plot_3data16(s16 v1, s16 v2, s16 v3);
void plot_2data16(s16 v1, s16 v2);
void plot_1data16(s16 v1);

/* logger functions */
#define sys_debug(fmt, args...) log_debug(MOD_SYSTEM, fmt, ##args)
#define sys_warning(fmt, args...) log_warning(MOD_SYSTEM, fmt, ##args)
#define sys_error(fmt, args...) log_error(MOD_SYSTEM, fmt, ##args)
#else
#include "simstruc.h"
extern FILE * fp_debug;
#define sys_debug_file(fmt, args...) \
do {\
	if (fp_debug) fprintf(fp_debug, fmt, ##args); fflush(fp_debug);\
}while(0)
#define sys_debug(fmt, args...)   sys_debug_file(fmt, ##args)
#define sys_warning(fmt, args...) sys_debug_file("Warnning: "fmt, ##args)
#define sys_error(fmt, args...)   sys_debug_file("Error: "fmt, ##args)
static void set_log_level(int mod, int l){}
#endif
#define no_debug(fmt, args...) {}

#endif /* _Shark_Logger_h__ */

